<template>
    <h2>修改页面</h2>
    <table>
        <tr>
            <td>
                投资名称:
            </td>
            <td>
                <input type="text" v-model="Name" id="Name" />
            </td>
        </tr>
        <tr>
            <td>
                总额度:
            </td>
            <td>
                <input type="text" v-model="Alls" id="Alls" />
            </td>
        </tr>
        <tr>
            <td>

            </td>
            <td>
                <input type="button" value="修改" @click="Upa">
            </td>
        </tr>
    </table>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { useRoute } from 'vue-router';
import { onMounted } from 'vue';
import axios from 'axios';



const router = useRoute()
const Name = ref('');
const Alls = ref('');
const Id = router.params.Id;

const route = useRoute();
onMounted(() => {
    axios.get('http://localhost:31285/api/Demo/Fans', {
        params: {
            Id: Id,
        }
    })
        .then(res => {
            Name.value = res.data.Name;
            Alls.value = res.data.Alls;
        })
        .catch(error => {
            console.log(error);
        })
})
const Upa = () => {

    axios.post('http://localhost:31285/api/Demo/Upa', {
        Name: Name.value,
        Alls: Alls.value,
        Id: Id
    })
        .then(res => {
            if (res.data > 0) {
                alert("修改成功");
                location.href = '/Show'
                return;
            }
            else {
                alert("修改失败");
                return;
            }
        })
        .catch(error => {
            console.log(error);
        })
}

</script>